/*
 * Copyright (c) 2018-2999 九五云信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 */

package com.yami.shop.live.multishop.controller;

import com.yami.shop.live.comment.model.LiveProdLog;
import com.yami.shop.live.comment.service.LiveProdLogService;
import com.yami.shop.common.annotation.SysLog;

import javax.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import lombok.AllArgsConstructor;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yami.shop.common.util.PageParam;
import com.baomidou.mybatisplus.core.metadata.IPage;


/**
 *
 *
 * @author LGH
 * @date 2020-08-04 16:57:17
 */
@RestController
@AllArgsConstructor
@RequestMapping("/live/liveProdLog" )
public class LiveProdLogController {

    private final LiveProdLogService liveProdLogService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param liveProdLog
     * @return 分页数据
     */
    @GetMapping("/page" )
    public ResponseEntity<IPage<LiveProdLog>> getLiveProdLogPage(PageParam<LiveProdLog> page, LiveProdLog liveProdLog) {
        return ResponseEntity.ok(liveProdLogService.page(page, new LambdaQueryWrapper<LiveProdLog>()));
    }


    /**
     * 通过id查询
     * @param liveProdLogId id
     * @return 单个数据
     */
    @GetMapping("/info/{liveProdLogId}" )
    public ResponseEntity<LiveProdLog> getById(@PathVariable("liveProdLogId") Long liveProdLogId) {
        return ResponseEntity.ok(liveProdLogService.getById(liveProdLogId));
    }

    /**
     * 新增
     * @param liveProdLog
     * @return 是否新增成功
     */
    @SysLog("新增" )
    @PostMapping
    public ResponseEntity<Boolean> save(@RequestBody @Valid LiveProdLog liveProdLog) {
        return ResponseEntity.ok(liveProdLogService.save(liveProdLog));
    }

    /**
     * 修改
     * @param liveProdLog
     * @return 是否修改成功
     */
    @SysLog("修改" )
    @PutMapping
    public ResponseEntity<Boolean> updateById(@RequestBody @Valid LiveProdLog liveProdLog) {
        return ResponseEntity.ok(liveProdLogService.updateById(liveProdLog));
    }

    /**
     * 通过id删除
     * @param liveProdLogId id
     * @return 是否删除成功
     */
    @SysLog("删除" )
    @DeleteMapping("/{liveProdLogId}" )
    public ResponseEntity<Boolean> removeById(@PathVariable Long liveProdLogId) {
        return ResponseEntity.ok(liveProdLogService.removeById(liveProdLogId));
    }

}
